package com.yc154.web.feign;

import com.yc154.entity.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

// 一个FeignClient对应一个服务
@FeignClient(value = "cloud-user", fallback = UserActionImpl.class)
public interface UserAction {
    @RequestMapping("user")
    String user();

    @RequestMapping("add")
    int add(@RequestParam("a") int a, @RequestParam("b") int b);

    @RequestMapping("hello/{name}")
    String hello(@PathVariable("name") String name);

    //  @SpringQueryMap 可以将对象的属性转换为请求参数
    @RequestMapping("emp1")
    User emp1(@SpringQueryMap User emp);

    @RequestMapping("emp2")
    User emp2(@RequestBody User emp);

    // 不写任何注解, 默认是 @RequestBody
    @RequestMapping("emp1")
    User emp11(User emp);

    @RequestMapping("emp2")
    User emp22(@SpringQueryMap User emp);
}
